package org.xsk.network.tcp.string;

import java.io.*;
import java.net.Socket;

/**
 * description: 客户端
 * <p>
 * date: 2021/6/10 11:36
 * author: x-one
 */
public class LoginClient {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("localhost", 8000);
        // 发送请求
        OutputStream os = socket.getOutputStream();
        String info = "姓名：jim  密码12345";
        os.write(info.getBytes());
        socket.shutdownOutput();

        // 读回应
        InputStream is = socket.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String replu = null;
        while ((replu = br.readLine()) != null) {
            System.out.println("我是客户端，服务器说：" + replu);
        }
        br.close();
        is.close();
        os.close();
        socket.close();
    }
}
